package com.campus.commons.entity;

import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.IdType;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;
import java.io.Serializable;

import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

/**
 * <p>
 * 晚自习排课表
 * </p>
 *
 * @author Rin
 * @since 2020-12-24
 */
@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="EveningSubject对象", description="晚自习排课表")
@TableName(excludeProperty ={"className","classroomName"} )
public class EveningSubject implements Serializable {

    public static  String[] ex = {"class_name","classroom_name","student_name"};

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "id")
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    @ApiModelProperty(value = "课表日期")
    @JSONField(format = "yyyy-MM-dd")
    private Date date;

    @ApiModelProperty(value = "班级id")
    @TableField("classId")
    private Integer classid;

    public EveningSubject(Date date, Integer classid, Integer teacherId, String mess, Integer classroomid) {
        this.date = date;
        this.classid = classid;
        this.teacherId = teacherId;
        this.mess = mess;
        this.classroomid = classroomid;
    }
    @TableField(exist = false)
    private Integer classCount;
    private String className;

    public void setClassid(Integer classid) {
        this.classid = classid;
        Class aClass = Class.classes.get(classid);
        this.className = aClass.getClassname();
        this.classCount = aClass.getClassCount();
    }

    public void setTeacherId(Integer teacherId) {
        this.teacherId = teacherId;
        this.teacherName = Teacher.teachers.getOrDefault(teacherId,new Teacher()).getTeachername();
    }

    public void setClassroomid(Integer classroomid) {
        this.classroomid = classroomid;
        this.classroomName = ClassRoom.classrooms.get(classroomid);
    }

    @ApiModelProperty(value = "值班人员")
    @TableField("teacherId")
    private Integer teacherId;
    @TableField(exist = false)
    private String teacherName;

    @ApiModelProperty(value = "授课内容")
    private String mess;

    @ApiModelProperty(value = "教室id")
    @TableField("classRoomId")
    private Integer classroomid;
    private String classroomName;

}
